package com.eunion.web.cms.entity;

import java.io.Serializable;
import java.util.Map;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

import org.apache.commons.lang.StringUtils;

/**
 * 大学
 */
@Entity
@Table(name = "university")
public class University implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    /**
     * 学校代码
     */
    @Column(name = "code")
    private String code;

    /**
     * 学校名称
     */
    @Column(name = "name")
    private String name;

    /**
     * 学校简称
     */
    @Column(name = "short_name")
    private String shortName;

    /**
     * 英文名
     */
    @Column(name = "en_name")
    private String enName;

    /**
     * 大学层级，本科、专科
     */
    @Column(name = "level")
    private String level;

    /**
     * 省ID
     */
    @Column(name = "province_id")
    private int provinceId;

    /**
     * 市ID
     */
    @Column(name = "city_id")
    private int cityId;

    /**
     * 区ID
     */
    @Column(name = "county_id")
    private int countyId;

    /**
     * 隶属
     */
    @Column(name = "belong")
    private String belong;

    /**
     * 办学性质，公办、民办
     */
    @Column(name = "classify")
    private String classify;

    /**
     * 建校年份
     */
    @Column(name = "creation")
    private String creation;

    /**
     * 学校标签，211,985,双一流等
     */
    @Column(name = "tags")
    private String tags;

    /**
     * 综合排名
     */
    @Column(name = "rank")
    private Integer rank;

    /**
     * 院校类型，综合，财经
     */
    @Column(name = "type")
    private String type;

    /**
     * 博士后数量
     */
    @Column(name = "bohou_points")
    private Integer bohouPoints;

    /**
     * 博士数量
     */
    @Column(name = "bo_points")
    private Integer boPoints;

    /**
     * 硕士数量
     */
    @Column(name = "shuo_points")
    private Integer shuoPoints;

    /**
     * 校徽图片地址
     */
    @Column(name = "logo_url")
    private String logoUrl;

    /**
     * 国家重点学科
     */
    @Column(name = "import_subject")
    private String importSubject;

    /**
     * 院系设置
     */
    @Column(name = "college_set")
    private String collegeSet;

    /**
     * 详细地址
     */
    @Column(name = "address")
    private String address;

    /**
     * 校训
     */
    @Column(name = "motto")
    private String motto;

    /**
     * 学校官网
     */
    @Column(name = "website")
    private String website;

    /**
     * 校庆日
     */
    @Column(name = "anniversary")
    private String anniversary;

    /**
     * 现任领导
     */
    @Column(name = "leader")
    private String leader;

    /**
     * 知名校友
     */
    @Column(name = "classmate")
    private String classmate;


    @Column(name = "province_name")
    private String provinceName;

    @Column(name = "city_name")
    private String cityName;
    
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getShortName() {
        return shortName;
    }

    public void setShortName(String shortName) {
        this.shortName = shortName;
    }

    public String getEnName() {
        return enName;
    }

    public void setEnName(String enName) {
        this.enName = enName;
    }

    public String getLevel() {
        return level;
    }

    public void setLevel(String level) {
        this.level = level;
    }

    public int getProvinceId() {
        return provinceId;
    }

    public void setProvinceId(int provinceId) {
        this.provinceId = provinceId;
    }

    public int getCityId() {
        return cityId;
    }

    public void setCityId(int cityId) {
        this.cityId = cityId;
    }

    public int getCountyId() {
        return countyId;
    }

    public void setCountyId(int countyId) {
        this.countyId = countyId;
    }

    public String getBelong() {
        return belong;
    }

    public void setBelong(String belong) {
        this.belong = belong;
    }

    public String getClassify() {
        return classify;
    }

    public void setClassify(String classify) {
        this.classify = classify;
    }

    public String getCreation() {
        return creation;
    }

    public void setCreation(String creation) {
        this.creation = creation;
    }

    public String getTags() {
        return tags;
    }

    public void setTags(String tags) {
        this.tags = tags;
    }

    public Integer getRank() {
        return rank;
    }

    public void setRank(Integer rank) {
        this.rank = rank;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public Integer getBohouPoints() {
        return bohouPoints;
    }

    public void setBohouPoints(Integer bohouPoints) {
        this.bohouPoints = bohouPoints;
    }

    public Integer getBoPoints() {
        return boPoints;
    }

    public void setBoPoints(Integer boPoints) {
        this.boPoints = boPoints;
    }

    public Integer getShuoPoints() {
        return shuoPoints;
    }

    public void setShuoPoints(Integer shuoPoints) {
        this.shuoPoints = shuoPoints;
    }

    public String getLogoUrl() {
        return logoUrl;
    }

    public void setLogoUrl(String logoUrl) {
        this.logoUrl = logoUrl;
    }

    public String getImportSubject() {
        return importSubject;
    }

    public void setImportSubject(String importSubject) {
        this.importSubject = importSubject;
    }

    public String getCollegeSet() {
        return collegeSet;
    }

    public void setCollegeSet(String collegeSet) {
        this.collegeSet = collegeSet;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getMotto() {
        return motto;
    }

    public void setMotto(String motto) {
        this.motto = motto;
    }

    public String getWebsite() {
        return website;
    }

    public void setWebsite(String website) {
        this.website = website;
    }

    public String getAnniversary() {
        return anniversary;
    }

    public void setAnniversary(String anniversary) {
        this.anniversary = anniversary;
    }

    public String getLeader() {
        return leader;
    }

    public void setLeader(String leader) {
        this.leader = leader;
    }

    public String getClassmate() {
        return classmate;
    }

    public void setClassmate(String classmate) {
        this.classmate = classmate;
    }

    /**
     * 从map中得到大学信息
     * @param map
     * @return
     */
    public static University getFromMap(Map<String, String> map) {
        University u = new University();

        u.setCode(map.get("code"));
        u.setShortName(map.get("shortName"));
        u.setName(map.get("name"));
        u.setEnName(map.get("enName"));
        u.setImportSubject(map.get("importSubject"));
        u.setAddress(map.get("address"));
        u.setCollegeSet(map.get("collegeSet"));
        u.setType(map.get("type"));
        u.setMotto(map.get("motto"));
        u.setWebsite(map.get("website"));
        u.setAnniversary(map.get("anniversary"));
        u.setLeader(map.get("leader"));

        if (StringUtils.isNotBlank(map.get("bohouPoints"))) {
            u.setBohouPoints(Integer.parseInt(map.get("bohouPoints")));
        }

        if (StringUtils.isNotBlank(map.get("boPoints"))) {
            u.setBoPoints(Integer.parseInt(map.get("boPoints")));
        }

        if (StringUtils.isNotBlank(map.get("shuoPoints"))) {
            u.setShuoPoints(Integer.parseInt(map.get("shuoPoints")));
        }

        u.setLogoUrl(map.get("logoUrl"));
        u.setCreation(map.get("creation"));
        u.setClassify(map.get("classify"));
        u.setTags(map.get("tags"));
        u.setClassmate(map.get("classmate"));
        return u;
    }

    public String getProvinceName() {
        return provinceName;
    }

    public void setProvinceName(String provinceName) {
        this.provinceName = provinceName;
    }

    public String getCityName() {
        return cityName;
    }

    public void setCityName(String cityName) {
        this.cityName = cityName;
    }
}
